AutoARIMA on Stock Prices

Choosing Stocks that have significantly lost value in the past few years

Preprocessing Data

Scale the data using a logarithmic scale. Also rounding the log result by 2 decimal points in order to reduce any unnecessary noise.

Visualizing the Data

Optimum Parameter Search Function

Using the ARIMA Model

Using the price history from the past N days to make predictions

Predictions vs Actual Values

Plotting the Predictions

Comparing the actual values with the predictions

Evaluation Metric

Trading Signal

Turning the model into a Trading Signal

Creating a Trading DF

Note: On Preventing Lookahead Bias

For example, if the model is ran after hours and a position is established on the next day's opening, then a shift ahead of 1 is ok. But if a position is established on the next day, near the close, then it needs to be shifted ahead by 2, because the newly established position missed any gains or losses that day. These are due to the fact that gains or losses in the day are determined when a trade is entered.

(This can also determine how long the predicted forecast remains valid.)

Plotting the Positions

Calculating and Plotting the Potential Returns

Returns on Each Individual Stock

Returns on the Overall Portfolio